package com.taobao.tql.hsf;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.taobao.sellerservice.core.client.OnlineSellerReadService;
import com.taobao.sellerservice.core.client.domain.OnlineSellerDO;
import com.taobao.sellerservice.core.client.impl.OnlineSellerReadServiceClient;
import com.thoughtworks.xstream.XStream;

/**
 * 
*
* @类名称：HsfCoverService
* @类描述：测试类，直接调用HSF服务
* @创建人：卫缺
* @修改人：卫缺
* @修改时间：2011-7-5 上午10:45:47
* @修改备注：
* @version 1.0.0
*
 */
public class HsfCoverService {

	ApplicationContext ac = new ClassPathXmlApplicationContext("ark-sellercenter-client.xml");
	 private XStream xstream = new XStream();
	private OnlineSellerReadService onlineSellerReadService = (OnlineSellerReadServiceClient) ac.getBean("onlineSellerReadService");
	
	/**
	 * 
	 * getSellerInof(这里用一句话描述这个方法的作用)
	 * (这里描述这个方法适用条件 – 可选)
	 * @since 1.0.0
	 */
	public String getSellerInof(Long sellerId) {
		//Long sellerId = 126L;
		OnlineSellerDO onlineSellerDO = new OnlineSellerDO();

			try {
				onlineSellerDO = onlineSellerReadService.getOnlineSellerById(sellerId);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				return null;
			}
		
		
		StringBuilder strBuild = new StringBuilder(writeBean2XML(onlineSellerDO));
		
		/*strBuild.append("<Address>").append(onlineSellerDO.getAddress()).append("</Address>");
		strBuild.append("<AlipayAccount>").append(onlineSellerDO.getAlipayAccount()).append("</AlipayAccount>");
		strBuild.append("<AlipayEmail>").append(onlineSellerDO.getAlipayEmail()).append("</AlipayEmail>");
		strBuild.append("<Company>").append(onlineSellerDO.getCompany()).append("</Company>");
		strBuild.append("<ApplyNick>").append(onlineSellerDO.getApplyNick()).append("</ApplyNick>");*/
		return strBuild.toString();
	}

	public void setOnlineSellerReadService(OnlineSellerReadService onlineSellerReadService) {
		this.onlineSellerReadService = onlineSellerReadService;
	}
	
	
	public String writeBean2XML(Object bean) {
	    try {
	        //属性重命名
	        //xstream.aliasField("邮件", OnlineSellerDO.class, "email");
	        //包重命名
	       // xstream.aliasPackage("hoo", "com.hoo.entity");
	        return xstream.toXML(bean);
	    } catch (Exception e) {
	        e.printStackTrace();
	    }
	    return "";
	}

}
